//
//  MainViewCell.m
//  XRmenu-HD
//
//  Created by shengchao yang on 11-12-3.
//  Copyright (c) 2011年 home user. All rights reserved.
//

#import "MainViewCell.h"

@implementation MainViewCell
@synthesize celldata;

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(void) setCelldata:(PluPlu *)newcelldata
{
    celldata=newcelldata;
    //显示菜品名称
	if ([self viewWithTag:kTagOfStartLabel]) {
		UILabel *tl = (UILabel*)[self viewWithTag:kTagOfStartLabel];
		if (tl) {
            NSString *tempName=JsonFiled(newcelldata.ppNames);
            if ([tempName length]>=9) {
                tempName=[tempName substringToIndex:9];
            }
			[tl setText:tempName];
		}
	}
    //显示价格
    if ([self viewWithTag:kTagOfStartLabel+1]) {
		UILabel *tl = (UILabel*)[self viewWithTag:kTagOfStartLabel+1];
		if (tl) {
            NSString* unit=JsonFiled(newcelldata.ppUnits);
            NSString* price  = [NSString stringWithFormat:@"%@%0.2f",[APPSESSION.allconfig getStringValueAtPath:@"System Config/currency"],[newcelldata.ppPrice floatValue]];
            if ([newcelldata.ppPrice floatValue]==0) {
                price=loc(@"时价");
            }
			[tl setText:[NSString stringWithFormat:@"%@/%@",price,unit]];
		}
	}
    //默认不显示选中图片
    if ([self viewWithTag:kTagOfStartImgV+1]) {
        UIImageView *imgSelected=(UIImageView *) [self viewWithTag:kTagOfStartImgV+1];
        imgSelected.hidden=YES;
    }
}
//设置选中状态
-(void) setSelectedRow:(BOOL)selected{
    //设置选中图片
    if ([self viewWithTag:kTagOfStartImgV+1]) {
        UIImageView *imgSelected=(UIImageView *) [self viewWithTag:kTagOfStartImgV+1];
        imgSelected.hidden=!selected;
    }
    if (selected) {//选中状态
        //设置菜品名称颜色
        if ([self viewWithTag:kTagOfStartLabel]) {
            UILabel *tl = (UILabel*)[self viewWithTag:kTagOfStartLabel];
            [tl setTextColor:[UIColor yellowColor]];
        }
        //设置价格颜色
        if ([self viewWithTag:kTagOfStartLabel+1]) {
            UILabel *tl = (UILabel*)[self viewWithTag:kTagOfStartLabel+1];
            [tl setTextColor:[UIColor yellowColor]];
        }
    }
    else{
        //设置菜品名称颜色
        if ([self viewWithTag:kTagOfStartLabel]) {
            UILabel *tl = (UILabel*)[self viewWithTag:kTagOfStartLabel];
            [tl setTextColor:[UIColor whiteColor]];
        }
        //设置价格颜色
        if ([self viewWithTag:kTagOfStartLabel+1]) {
            UILabel *tl = (UILabel*)[self viewWithTag:kTagOfStartLabel+1];
            [tl setTextColor:[UIColor whiteColor]];
        }
    }
}
@end
